"""SchoolProject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework import routers, serializers, viewsets
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from accounts import views
from accounts.views import *
from workflows.views import *
from rest_framework.response import Response
from rest_framework.documentation import include_docs_urls

from .views import test_

schema_view = get_schema_view(
    openapi.Info(
        title="川应接口文档平台",  # 必传
        default_version="v1",  # 必传
        description="川应后台管理系统接口",
        terms_of_service="admin/",  # 跳转界面
        # contact=openapi.Contact(email="mhhcode@mhhcode.com"),
        license=openapi.License(name="后台兼文档平台作者：汐鹿生")
    ),
    public=True,
)

urlpatterns = [
    path('__debug__/', include('debug_toolbar.urls')),
    path('admin/', admin.site.urls),
    path('', test_),
    # 信息模块路由
    url(r'', include('accounts.urls')),
    # 文件模块路由
    url(r'', include('file.urls')),
    # 日志模块路由
    url(r'', include('journal.urls')),
    # 爬虫模块路由
    url(r'', include('reptile.urls')),
    # 微信模块路由
    url(r'^weixing', include('weixing.urls')),
    # 接口文档1
    path('doc/', schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger"),
    # 接口文档2
    # path("redoc/", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
    # token登录接口
    url(r'^login', obtain_jwt_token),
    # 富文本编辑器路由
    path('ckeditor/', include('ckeditor_uploader.urls')),
    url(r'^workflow_submit/(?P<version>[v1|v2]+)/$', WorkflowSubmit.as_view(), name='workflow_submit'),
    url(r'^workflow_approve/(?P<version>[v1|v2]+)/$', WorkflowApprove.as_view(), name='workflow_approve'),
    url(r'^check_valid_title/(?P<version>[v1|v2]+)/$', CheckValidTitle.as_view(), name='check_valid_title'),
    url(r'^get_approve_chain/(?P<version>[v1|v2]+)/$', GetApproveChain.as_view(), name='get_approve_chain'),
    url(r'^list_my_applied/(?P<version>[v1|v2]+)/$', ListMyApplied.as_view(), name='list_my_applied'),
    url(r'^list_workflow/(?P<version>[v1|v2]+)/$', ListWorkflow.as_view(), name='list_workflow'),
    url(r'^workflow_detail/(?P<version>[v1|v2]+)/$', WorkflowDetail.as_view(), name='workflow_detail'),
    url(r'^list_my_approval_pending/(?P<version>[v1|v2]+)/$', ListMyApprovePending.as_view(),
        name='list_my_approval_pending'),
    url(r'^list_my_approved/(?P<version>[v1|v2]+)/$', ListMyApproved.as_view(), name='list_my_approved'),
    url(r'^get_approve_pending_cnt/(?P<version>[v1|v2]+)/$', GetApprovePendingCnt.as_view(), name='get_approve_pending_cnt'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)  # 静态文件路由
